package com.stone.business.plan.service;

/**
 * <pre>
 * ---计划---Service
 * </pre>
 */

import java.util.HashMap;
import java.util.List;

import com.stone.business.plan.pojo.TGzrwdOld;

import com.stone.business.plan.pojo.TPlanBz;
import frm.ssh.exception.AppException;
import frm.ssh.service.BaseService;


public class GzrwCreatePlanService extends BaseService{
	
	/**
	 * ....保存计划....
	 */
	public String doSave(TGzrwdOld entity,String hiddenids) {
		
		String strbz = "";
		
		if (entity.getId() == 0 || entity.getId() == null) {

			super.save(entity);
		// 审核通过
	/*	if (!StringUtils.isNullOrBlank(hiddenids)) {
			if (hiddenids.startsWith(",")) {
				hiddenids = hiddenids.substring(1, hiddenids.length());
			}
			if (hiddenids.endsWith(",")) {
				hiddenids =hiddenids.substring(0, hiddenids.length()-1);
			}
			super.updateByDHql("state = '9'", "id in (" + hiddenids + ")", null, null, TGzrwd.class.getName());
			return "审核通过。";*/
		}
		
		return "保存成功。";
	}
	
	/**
	 * ....提交计划....
	 */
	public String doSubmit(TGzrwdOld entity,String status) {
		
		entity.setState(status);
		super.update(entity);
		return "提交成功。";
	}
	
	
	/**
	 * 删除
	 */
	public void delete(Long id) throws AppException {
		// 删除节点菜单
		super.delete(id, "Plan");
		// 删除按钮
		super.deleteByDHql("parentID = ? and btnId is not null", new Object[]{id}, "Plan");
	}

	/**
	 * 执行Hql查询查询
	 * 
	 * @param hql  查询语句
	 * @return List 结果集
	 */
	public List findListByHql(String hql)  {
			return super.findListByHql(hql);
	}
	
	/**
	 * 根据ID查询记录
	 * 
	 * @param id ID
	 * @param objectFullName POJO名 包括包路径
	 * @return Object
	 */
	public Object findById(Long id, String objectFullName)  {
		return super.findById(id, objectFullName);
	}
	
	/**
	 * 保存pojo对象
	 * 
	 * @param transientInstance pojo对象
	 */
	public void save(Object transientInstance)  {
			super.save(transientInstance);
	}
	
	/**
	 * 修改记录
	 * 
	 * @param transientInstance pojo对象
	 */
	public void update(Object transientInstance)  {
			super.update(transientInstance);
	}
	
	/**
	 * 修改记录
	 * 
	 * @param transientInstance pojo对象
	 */
	public void doDelAll(final String ids,final String objectSimpleName)  {
			super.doDelAll(ids,objectSimpleName);
	}
	
	/**
	 * 通过SQL查询列表，返回每条是一个HashMap<String,Object>
	 * @param sql 查询SQL语句
	 * @return list 返回列表
	 */
	public List<HashMap<String,Object>> findListBySql(String sql){
	
		List<HashMap<String,Object>> list =  (List<HashMap<String,Object>>) super.findListBySql(sql);
		return list;
	}

	
	/**
	 * 此方法是用来动态获取列表，可以多表关联
	 * 
	 * @param cols 查询列名
	 * @param conditions 查询条件
	 * @param vals 查询条件对应值
	 * @return clause order by, group by,having等子句
	 * @param objectSimpleName 
	 */
	public List getListByDHql(final String cols, final String conditions,
			final Object[] vals, final String clause,
			final String objectSimpleName)  {
		
		return super.getListByDHql(cols, conditions, vals, clause, objectSimpleName);
	}
	
	/**
	 * 根据ID删除记录
	 * 
	 * @param id 删除记录的ID
	 * @param objectSimpleName
	 */
	public void delete(Long id, String objectSimpleName){
			super.delete(id, objectSimpleName);
	}
	/**
	 * 通过HQL修改记录
	 * 
	 * @param hql 修改的HQL语句
	 * @param values HQL语句对应值
	 */
	public void updateByHQL(String hql, Object[] values){
		super.updateByHQL(hql,values);
	}
}
